import axios from 'axios';

axios.defaults.maxBodyLength = 5 * 1024 * 1024;
axios.defaults.withCredentials = true;

const Axios = axios.create({
    baseURL: import.meta.env.VITE_APP_BASE_URL,
    timeout: 3000,
    headers: {
        "Content-Type": "application/json; charset=utf-8"
    },
    withCredentials: true
})

Axios.interceptors.request.use(
    (config) => {
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)

Axios.interceptors.response.use((res) => {
    console.log('请求成功')
    return res
}, (error) => {
    console.log('请求失败了')
    return Promise.reject(new error('请求失败'))
})

export default Axios